home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / Terminal 2.2 / Project / Sources / About.c next >
Text File  |  1992-01-17  |  2KB  |  110 lines

  1. /*
  2.     Terminal 2.2
  3.     "About.c"
  4. */
  5.  
  6. #ifdef THINK_C
  7. #include "MacHeaders"
  8. #endif
  9. #ifdef applec
  10. #pragma load ":(Objects):MacHeadersMPW"
  11. #pragma segment About
  12. #endif
  13.  
  14. #include "Text.h"
  15. #include "Main.h"
  16. #include "Utilities.h"
  17.  
  18. #define AboutOk        1
  19. #define AboutText    2
  20. #define AboutIcon    3
  21. #define AboutHp        4
  22. #define AboutVers    5
  23. #define AboutLine1    6
  24. #define AboutLine2    7
  25.  
  26. char Erny[] = 
  27.     "\pWritten by:\015  Erny Tontlinger (CIS 73720,2200)\015"
  28.     "  33, route d'Arlon\015  L-8410 Steinfort\015  Luxembourg";
  29.  
  30. /* ----- Get long version message from 'vers' resource ----------------- */
  31.  
  32. static void GetVersion(
  33.     register short id,
  34.     register Byte *message)
  35. {
  36.     register Handle h;
  37.     register Byte *p;
  38.  
  39.     if (h = GetResource('vers', id)) {
  40.         p = (Byte *)*h;
  41.         p += 7 + p[6];
  42.         memcpy(message, p, (long)(p[0] + 1));
  43.         ReleaseResource(h);
  44.     } else
  45.         message[0] = 0;
  46. }
  47.  
  48. /* ----- Draw user item in dialog box ---------------------------------- */
  49.  
  50. static pascal void DrawUser(    /* Called by Dialog Manager */
  51.     register DialogPtr dialog,
  52.     register short item)
  53. {
  54.     register Handle h;
  55.     short type;
  56.     Handle itemHdl;
  57.     Rect box;
  58.  
  59.     GetDItem(dialog, item, &type, &itemHdl, &box);
  60.     if (h = GetResource('ICN#', Application.icon)) {
  61.         HLock(h);
  62.         PlotIcon(&box, h);
  63.         HUnlock(h);
  64.     }
  65. }
  66.  
  67. /* ----- About... dialog ----------------------------------------------- */
  68.  
  69. void About(short option)
  70. {
  71.     register Handle IDStrHandle;
  72.     register Byte *s;
  73.     register DialogPtr dialog;
  74.     register long heap;
  75.     long grow;
  76.     short item;
  77.     Handle itemHdl;
  78.     Rect box;
  79.     Byte num[256];
  80.  
  81.     heap = MaxMem(&grow);
  82.     s = (Byte *)Erny;
  83.     if (option & (optionKey | cmdKey | shiftKey | controlKey))
  84.         IDStrHandle = 0;
  85.     else
  86.         if (IDStrHandle = GetResource(Application.signature,
  87.                 Application.version)) {
  88.             HLock(IDStrHandle);
  89.             s = (Byte *)*IDStrHandle;
  90.         }
  91.     CenterDialog('DLOG', DLOG_ABOUT);
  92.     if (dialog = GetNewDialog(DLOG_ABOUT, 0, (WindowPtr)-1L)) {
  93.         SetEText(dialog, AboutText, s);
  94.         NumToString(heap, num);
  95.         SetEText(dialog, AboutHp, num);
  96.         GetDItem(dialog, AboutIcon, &item, &itemHdl, &box);
  97.         SetDItem(dialog, AboutIcon, item, (Handle)DrawUser, &box);
  98.         GetDItem(dialog, AboutLine1, &item, &itemHdl, &box);
  99.         SetDItem(dialog, AboutLine1, item, (Handle)DrawUserLine, &box);
  100.         GetDItem(dialog, AboutLine2, &item, &itemHdl, &box);
  101.         SetDItem(dialog, AboutLine2, item, (Handle)DrawUserLine, &box);
  102.         GetVersion(1, num);
  103.         SetEText(dialog, AboutVers, num);
  104.         ModalDialog(0, &item);
  105.         DisposDialog(dialog);
  106.     }
  107.     if (IDStrHandle)
  108.         ReleaseResource(IDStrHandle);
  109. }
  110.